﻿<?php session_start();
	include '../dyn/connexion.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="fr" xml:lang="fr">

<head>
	<meta content="text/html; charset=UTF-8" http-equiv="content-type" />
	<title>L'espace adhérent</title>
	<link rel="stylesheet" href="../css/style.css" type="text/css" />
	
	<script type='text/javascript' src='../ckeditor/ckeditor.js'></script>
	<script type='text/javascript'>
		function controles(){
			alert("bla");
			if (document.form.title.value == "")
			{
					//alert("bla");
					document.getElementById("erreur").style.display='block';
					document.getElementById("result").style.display='none';
					return false;
			}else{
				var XMLHttpRequestObject = false;
				if (window.XMLHttpRequest) {
					XMLHttpRequestObject = new XMLHttpRequest();
				} else if (window.ActiveXObject) {
					XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
				}
				
				if(XMLHttpRequestObject) {
					XMLHttpRequestObject.open("POST", "inserttexte.php");
					var myJSON={"title":document.getElementById("title").value,"texte":document.getElementById("content").value};
					XMLHttpRequestObject.send("param"=+myJSON);
				}
				return true;
			}
			
		}
	</script>
	<script language = "javascript">
		
	</script>
</head>

<body>
	<div id="conteneur">
		
		<?php include "menu.php"; ?>

	
		<div id="contenu">
			<p id="ariane">Vous êtes ici : <a id ="accueil" href="../index.html" title="revenir à l'accueil">accueil</a> > espace adhérent</p>
			<?php include "right_menu.php";?>
			
			<h1 id="un">Publiez un texte</h1>
			<div class="main">
			<?php if(isset($_SESSION['connect']) AND $_SESSION['connect']==true){  ?>
				<p> Vous pouvez via cette page publier vos textes.</p><br/>
				
				<form id='new'  name='form' onSubmit='controles();' >
					<?php
						
					?>
					
					<label for='title'>Titre du texte :<label></td><td><input type='text' size='84' name='title' id='title'/>
					<p><span id='erreur' style="border:3px solid silver; color:red; display:none; width:70%;">Vous devez saisir un titre avant de publier !</span></p>
					<textarea  id="content" name="editor"  >
					  Saisissez votre texte ici
				   </textarea>
				   
				  
					
					<input type='submit' value='Publier'/>
				</form>
				<script type="text/javascript">
				  var editor = CKEDITOR.replace(
					 'content'
				  );
				</script>
			<?php
			}
			
			
			?>
			</div>
		</div>
	</div>
	
	<?php include "foot.php";?>
</body>

</html>
